WEBVTT

00:02.380 --> 00:08.730
Hello and welcome to the none pay assessment Crist's solution so same as with the pace and basic.

00:08.740 --> 00:13.510
We have 15 questions that cover all topics we need for our sticker.

00:13.600 --> 00:15.780
Case study and.

00:15.930 --> 00:21.070
Yeah if you have the impression that you need some more background on the basics feel free to watch

00:21.070 --> 00:27.400
the next few sessions about the basic none pay coding and follow up questions.

00:27.400 --> 00:31.570
We have the assumption that we already imparted an umpire.

00:32.500 --> 00:34.110
So let's start our quiz

00:37.810 --> 00:44.980
and the key message of the first question is that none pay array only contains one data type and by

00:44.980 --> 00:48.790
converting a list the different data types into a new pay array.

00:48.790 --> 00:52.060
All elements are converted to one data type.

00:52.240 --> 00:54.310
Actually to the lowest common denominator.

00:54.310 --> 00:57.760
And in this case that's the data type string.

00:57.760 --> 01:03.910
So with quotation marks we can transform an integer and will end and float to a string.

01:03.910 --> 01:06.580
So that correct answers string only

01:12.090 --> 01:19.050
here on this question we have an umpire ravers five elements and we have a so-called vector rise or

01:19.110 --> 01:23.670
element y's operation and where we add tend to each element.

01:24.210 --> 01:28.420
So actually we should get the eleven twelve thirteen fourteen fifteen.

01:28.420 --> 01:30.130
So this is correct yeah.

01:30.420 --> 01:37.080
And the key message is that in contrast to lists element y's operations are pretty easy here with an

01:37.080 --> 01:37.470
umpire

01:43.390 --> 01:48.790
so here we have two codes and they are we should determine how many of these codes the return uh the

01:48.790 --> 01:49.660
output.

01:49.690 --> 01:51.960
Six nine twelve 15 18.

01:52.210 --> 01:54.540
And let's have a look at the code one.

01:55.150 --> 02:02.140
So also here we have an element of ICE operation where we first add to and then multiply with three.

02:02.170 --> 02:12.250
So let's start with zero plus two is two times three is six then one plus two is three times three is

02:12.250 --> 02:24.440
nine two plus two is four times three is twelve three plus two is five times three is fifteen and four

02:24.440 --> 02:28.570
plus two is six times three is eighteen.

02:28.670 --> 02:36.580
So code 1 works and let's have a look at CO 2 Here we have the function P arrange and NPR range arranges

02:36.650 --> 02:44.600
integers and the range from six including to 19 excluding and only every third element.

02:44.630 --> 02:54.250
So we are starting with six then we have nine 12 15 and 18 so also Code 2 produces this output here.

02:54.320 --> 02:57.470
So the correct answer is both

03:03.420 --> 03:09.510
so here in this question we have a higher rate with 10 elements and we slicing from the next position

03:09.510 --> 03:17.410
for including to the next position eight excluding and also here the zero based indexing applies.

03:17.400 --> 03:25.440
So we start here with the 0 1 2 3 4.

03:25.620 --> 03:36.340
So our first element of our slices the 5 5 6 7 8 excluding.

03:36.360 --> 03:38.970
So our last element and our slices eight.

03:39.690 --> 03:47.290
So this should be the correct answer.

03:47.390 --> 03:55.640
Here we have some num pi array of us five elements 10 20 30 40 50 and we assign the arrival right a

03:56.960 --> 03:59.180
and then we make a slice of array.

03:59.180 --> 04:08.720
So we take them the first two elements and assign the variable array B so or a B contains of the elements

04:08.780 --> 04:18.740
10 and 20 and then we change the first element of array B and set it to 1 then actually so this answer

04:18.800 --> 04:24.730
is correct the first element of array B is null 1 and actually give us num pay raise then we create

04:24.730 --> 04:28.300
here a slice of array we are not creating a copy.

04:28.430 --> 04:36.410
So Arabia is referencing to the same original object but only to the first two elements and if you change

04:36.710 --> 04:43.580
one of the first two elements of array B we also change the elements of array A's so array a the first

04:43.610 --> 04:45.640
element of array a small one.

04:45.980 --> 04:51.690
And if you want to prevent this behavior of your we have to make a copy of the array a.

04:51.770 --> 04:58.340
So this is a common source for mistakes actually you make a slice and change some element and a slice

04:58.450 --> 05:05.450
of an none pay array and then also the original A changes and we might not even recognize that.

05:05.480 --> 05:06.920
So this is important here

05:09.780 --> 05:10.040
okay.

05:10.050 --> 05:10.560
The question.

05:10.560 --> 05:10.870
Yes.

05:10.880 --> 05:11.190
Yes.

05:11.200 --> 05:16.460
Which statement is incorrect so incorrect as then that the first element of array is still tense.

05:16.490 --> 05:17.610
Oh no that's correct

05:21.590 --> 05:30.080
here we are creating a one dimensional array with elements from 0 to 7 and then we reshape the one dimensional

05:30.080 --> 05:36.170
array to a two dimensional matrix with four rows and two columns.

05:36.170 --> 05:39.350
So here we have four rows and two columns.

05:39.350 --> 05:41.560
And this is the correct answer.

05:47.110 --> 05:51.760
Here we have a matrix a two dimensional array with a shape 3 5.

05:51.760 --> 05:55.340
So we have three rows and five columns.

05:55.340 --> 05:59.370
And yeah we're we want to index seven.

05:59.380 --> 06:07.350
So here this row is that next position the row and the second row is that index position 1.

06:07.390 --> 06:14.710
So let's move to the column here is column at index position 0 column meeting index position 1 and column

06:14.710 --> 06:16.240
at index position 2.

06:16.690 --> 06:29.380
So row at index position 1 and column and index position 2 should last for 7.

06:29.450 --> 06:36.770
Again we have the same matrix and as this kind of a tricky question so we slice the matrix we take all

06:36.770 --> 06:40.840
rows and the column at an exposition too.

06:40.850 --> 06:46.700
So this this this column here and then we add 100 to each element.

06:46.860 --> 06:53.100
And if you would print this line of code here then you would end up with this answer here but actually

06:53.100 --> 06:57.160
here with this code we are not changing the Matrix itself.

06:57.240 --> 07:04.010
So we are not assigning new values to the column at an exposition tours or actually we haven't changed

07:04.140 --> 07:05.730
the original matrix at all.

07:05.730 --> 07:11.660
And the correct answer is yeah the first one so the matrix my matrix is unchanged.

07:18.590 --> 07:26.600
Here we want to create 20 random integers in the in terms of 1 to 10 both and including and we want

07:26.600 --> 07:29.770
to select all elements that are greater than 5.

07:30.050 --> 07:38.050
And we set up the random C to 1 2 3 to ensure our reproducibility and let's have a look at the answers.

07:38.120 --> 07:42.910
So we want to create 20 random integers in the interval 1 to 10.

07:43.040 --> 07:49.130
So the starting point is including and the ending point and excluding and we need to have 20.

07:49.150 --> 07:54.670
So here this is correct and also this is correct and the second answer is not correct here.

07:54.950 --> 07:59.990
And now the second key message of this question is boolean indexing.

07:59.990 --> 08:08.090
So if you look here at this answer then for each of the 20 random integers we check whether the integer

08:08.090 --> 08:09.880
is greater than 5.

08:09.950 --> 08:16.910
And then we create here an NDA array with twenty billions and print here the end array with Julian's

08:17.880 --> 08:25.380
but actually we do not get here and the India test that's greater than 5 so he and the first answer

08:25.770 --> 08:32.580
we have are we in indexing so we select all elements of our array with 20 integers which are greater

08:32.580 --> 08:33.180
than 5

08:39.690 --> 08:42.810
here we calculate integers to the power of three of us.

08:42.810 --> 08:49.650
List comprehension and num pi code and the key message is that for large numerical operations like in

08:49.650 --> 08:53.700
this case here num pay us fifty two hundred times faster.

08:54.450 --> 09:02.510
So the fastest code should be here in the name pi code with only 1000 calculations and here for code

09:02.510 --> 09:06.030
number 1 and 2 with the same amount of calculation.

09:06.030 --> 09:10.750
So we have 100000 here the unpaid code should be much faster.

09:11.090 --> 09:19.160
So answer 3 to 1 is correct.

09:19.360 --> 09:25.810
Here we have an umpire array from 1 to twenty and we want to create a new array that contains all elements

09:25.930 --> 09:28.120
that fulfils two conditions.

09:28.210 --> 09:33.180
So first of all the element must be divisible by three without remainder.

09:33.730 --> 09:38.200
And the second condition is that the element three and must not be in the array.

09:38.200 --> 09:40.960
So we have two conditions and both must be met.

09:40.960 --> 09:42.610
So we need here and sign.

09:42.610 --> 09:45.260
Here we have an sign your F and or sign in here.

09:45.280 --> 09:48.420
And so this is not the correct answer.

09:48.550 --> 09:55.380
And what we need is really in slicing so this answer is incorrect as it returns only the boolean array

09:55.390 --> 09:58.860
is showing for each element of the array here.

09:59.080 --> 10:06.520
If both conditions are met but the answer does not return the elements itself that fulfill both conditions.

10:06.520 --> 10:08.190
Here we have two conditions.

10:08.200 --> 10:13.900
They are linked with an end and then we are creating as here a bully an array with truth or false for

10:13.900 --> 10:16.640
each element checking of each element.

10:16.670 --> 10:22.780
Fulfills both conditions and then we slice the array only for the elements that fulfill both conditions

10:22.790 --> 10:24.280
so this answer yes correct

10:27.780 --> 10:30.950
here we create 10 random normal distributed numbers.

10:30.960 --> 10:36.330
This mean 50 and standard deviation 10 and we calculate the mean.

10:36.480 --> 10:37.880
Over these 10 numbers.

10:37.920 --> 10:43.510
And we repeat this process 1000 times so we have 1000 simulations.

10:43.800 --> 10:48.360
And in the end we want to return an array with 1000 mean values.

10:48.420 --> 10:53.160
So the question is how many of the following codes are correct.

10:53.160 --> 10:54.180
And until.

10:54.180 --> 11:02.280
Here are three codes are identical so we create 10 times 1000 normal distributed numbers with mean 50

11:02.280 --> 11:04.430
and standard deviation 10.

11:04.560 --> 11:09.610
So we have 10000 the number distributed numbers and code 1.

11:09.690 --> 11:19.420
We reshape these 10000 numbers to 1000 rows and 10 columns and then for each row we take the mean over

11:19.420 --> 11:21.670
the 10 column so x equals 1.

11:22.510 --> 11:28.160
So here we should get a 1000 times the mean of 10 normal distributed numbers.

11:28.970 --> 11:38.510
And here in code to we reshape our 10000 numbers to 10 rows and 1000 columns and then we take the mean

11:38.570 --> 11:43.880
over all 1000 columns so 1000 times over 10 rows.

11:43.910 --> 11:51.170
So also here we should get an array with a 1000 the mean values and code 3 is actually identical to

11:51.200 --> 11:52.400
Kota 2.

11:52.580 --> 11:59.540
First of all we reshape the 10000 numbers into 1000 draws and ten columns and then we transpose the

11:59.540 --> 12:08.090
matrix into 10 rows and 1000 columns and then say mass and co 2 we take the mean for each of the 1000

12:08.090 --> 12:08.920
columns.

12:08.990 --> 12:21.320
So the answer is then that all three codes are correct.

12:21.400 --> 12:24.720
Here we have an array with seven elements from one to seven.

12:24.740 --> 12:30.080
And yeah gets code returns some the output far so we have fear in the middle of the four.

12:30.370 --> 12:35.450
And let's check what answers we have here so we have a person tired of the 19th person.

12:36.130 --> 12:42.860
We have the median and we have the sum so obviously the sum of their array cannot be for the person

12:42.860 --> 12:43.500
time.

12:43.520 --> 12:45.370
There are actually also not really.

12:45.470 --> 12:52.540
And the median is actually here the value where 50 percent of the other elements of the array is um

12:52.790 --> 12:55.530
less or lower than 50 percent is higher.

12:55.550 --> 13:02.800
So the fourth then the medium of our end the array and we can calculate the median with them the number

13:02.800 --> 13:04.480
of function and picked up medium

13:10.980 --> 13:17.160
so here we have a function Y equals cosine x plus except are we want to plot the graph and then Turnbull

13:17.160 --> 13:18.860
minus 10 to 10.

13:19.020 --> 13:22.230
And the question is which code best produces this graph.

13:22.230 --> 13:24.870
So let's have a look at our answers here.

13:26.510 --> 13:29.660
And to plot a graph you need how many data points.

13:29.660 --> 13:38.730
So NPL in space creates us 1000 evenly distributed data points in the interval minus 10 to 10 and MP

13:38.730 --> 13:43.570
range actually only creates 20 data points from minus 10 to 10.

13:43.610 --> 13:47.390
So this is not the optimal answer here.

13:47.390 --> 13:49.970
And comparing answer 2 and 3.

13:50.420 --> 13:54.370
So this in Python standard library no function like cosine.

13:54.380 --> 13:59.690
So we have to calculate the cosine with the number of function and picked up the coast.

13:59.780 --> 14:02.210
And this should be the correct answer here

14:06.910 --> 14:07.990
now our last question.

14:07.990 --> 14:14.290
So we have two dimensional data points that are represented by the ending arrays X for the x coordinate

14:14.950 --> 14:22.270
and y for the y coordinate and we want to fit a linear regression line that best fits the data points.

14:22.280 --> 14:28.180
Yeah the right function for it is the umpire function and P poorly fit where we pass them the arrays

14:28.190 --> 14:35.560
x and y and as we want to have a linear regression line our polynomial degrees should be 1 and not 2.

14:35.590 --> 14:38.770
So here we get a credit rhetoric regression.

14:38.770 --> 14:41.140
So the best answer here is the answer 1.
